package com.longrise.common.utils;

import java.util.ArrayList;

import android.app.Activity;

public class ActivityUtil {

	/** Activity栈 */
	private static ArrayList<Activity> activities = new ArrayList<Activity>();

	public static void addActivity(Activity activity) {
		if(!activities.contains(activity)){
			activities.add(activity);
		}
	}

	public static void finishAllAcivity() {
		for (Activity activity : activities) {
			activity.finish();
		}
		activities.clear();
	}

	public static void removeActivity(Activity activity) {
		activities.remove(activity);
	}

	public static int getActivityNum(){
		return activities.size();
	}

	public static Activity getTopActivity(){
		if(activities.size()==0){
			return null;
		}else{
			return activities.get(activities.size()-1);
		}
	}

	/**
	 * 判断这个activity是否关闭了
	 */
	public static boolean containThisActivity(Activity activity){
		return activities.contains(activity);
	}
}
